Skip to content

Report every failed document with its ID and reason#51

Merged
stevevanhooser merged 5 commits into
mainfrom
claude/dataset-document-error-handling-Cntyn
Mar 25, 2026
Merged

Report every failed document with its ID and reason#51
stevevanhooser merged 5 commits into
mainfrom
claude/dataset-document-error-handling-Cntyn

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor
  • Stop silently skipping FileExistsError (duplicates) in dataset init; report them alongside all other failures
  • Add _get_doc_id() helper for robust ID extraction in error messages
  • Each failure now shows "- <document_id>: " (e.g. "ndi_document abc123 already exists" or DID validation errors)
  • Remove misleading "see preceding warnings" from downloadDataset error
  • Keep FileExistsError skip only in add_ingested_session (re-ingestion)

https://claude.ai/code/session_015oe6ucKwCFznpu1PN1nAfz

claude added 5 commits March 25, 2026 16:03
- Stop silently skipping FileExistsError (duplicates) in dataset init;
  report them alongside all other failures
- Add _get_doc_id() helper for robust ID extraction in error messages
- Each failure now shows "- <document_id>: <reason>" (e.g.
  "ndi_document abc123 already exists" or DID validation errors)
- Remove misleading "see preceding warnings" from downloadDataset error
- Keep FileExistsError skip only in add_ingested_session (re-ingestion)

https://claude.ai/code/session_015oe6ucKwCFznpu1PN1nAfz
Store add failures on dataset instance (add_doc_failures) instead of
raising from __init__, so downloadDataset() can collect them and report
every failed document ID with its specific error reason in one error.

Error output now looks like:
  Downloaded 7221 documents but only 7123 were added to the dataset.
  98 document(s) lost:
  98 failed to add to the dataset database:
    - abc123def: ndi_document abc123def already exists
    - 456ghi789: <specific error from DID-python>
    ...

https://claude.ai/code/session_015oe6ucKwCFznpu1PN1nAfz
The 98 missing documents don't raise exceptions during database.add() -
DID-python silently fails to persist them. To diagnose:

- Cross-check uses raw DID get_doc_ids() instead of isa('base') query,
  which could miss docs whose type info wasn't stored correctly
- Missing document IDs are listed in the RuntimeError message
- Full JSON of all missing documents is written to
  missingDocuments.json in the dataset directory for inspection

https://claude.ai/code/session_015oe6ucKwCFznpu1PN1nAfz
Prevents test artifact databases from being tracked.

https://claude.ai/code/session_015oe6ucKwCFznpu1PN1nAfz
MATLAB's jsonencode unwraps single-element cell arrays to scalars.
Documents with only one superclass (e.g. just 'base') arrive from the
cloud with superclasses as a bare dict instead of a one-element list.
DID-python's _get_superclass_str only handles lists, so meta.superclass
was stored as empty string, causing isa('base') queries to miss 98 of
7221 documents.

The fix extends _normalize_depends_on (which already handles the same
MATLAB issue for depends_on and file_info) to also normalize
document_class.superclasses.

https://claude.ai/code/session_015oe6ucKwCFznpu1PN1nAfz
@stevevanhooser stevevanhooser merged commit 43ed8d2 into main Mar 25, 2026
5 checks passed
@stevevanhooser stevevanhooser deleted the claude/dataset-document-error-handling-Cntyn branch March 25, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants